//
//  CView.swift
//  CViews
//
//  Created by 任超华 on 2021/11/18.
//

import UIKit

class CView: UIView {

    /*
    // Only override draw() if you perform custom drawing.
    // An empty implementation adversely affects performance during animation.
    override func draw(_ rect: CGRect) {
        // Drawing code
    }
    */

}

public extension UIView {
    func clipCorner(_ corner:UIRectCorner = .allCorners){
//        let w = self.bounds.width
        let path = UIBezierPath.init(roundedRect: self.bounds,
                                     byRoundingCorners: corner,
                                     cornerRadii: CGSize(width: 20, height: 0))
        let layer = CAShapeLayer()
        layer.frame = self.bounds
        layer.path = path.cgPath
        self.layer.mask = layer
    }
    
    var x: CGFloat {
        set {
            var frame = self.frame
            frame.origin.x = newValue;
            self.frame = frame;
        }
        get {
            return self.frame.origin.x;
        }
    }
    
    var y: CGFloat {
        set {
            var frame = self.frame
            frame.origin.y = newValue;
            self.frame = frame;
        }
        get {
            return self.frame.origin.y;
        }
    }
    
    var width: CGFloat {
        set {
            var frame = self.frame
            frame.size.width = newValue;
            self.frame = frame;
        }
        get {
            return self.frame.size.width;
        }
    }
    
    var height: CGFloat {
        set {
            var frame = self.frame
            frame.size.height = newValue;
            self.frame = frame;
        }
        get {
            return self.frame.size.height;
        }
    }
    
    var size: CGSize {
        set {
            var frame = self.frame
            frame.size = newValue;
            self.frame = frame;
        }
        get {
            return self.frame.size;
        }
    }
    
    var origin: CGPoint {
        set {
            var frame = self.frame
            frame.origin = newValue;
            self.frame = frame;
        }
        get {
            return self.frame.origin;
        }
    }
    
    var maxX: CGFloat {
        get {
            return self.frame.maxX;
        }
    }
    
    var maxY: CGFloat {
        get {
            return self.frame.maxY
        }
    }
}
